package list.control;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by ZhipengLi.
 */
public abstract class Guest extends MysqlLink {
    private static final String TABLE = "guest";

    public String checkAuth(String auth) {
        String user;
        ResultSet resultSet = select(TABLE, ALL, equal("auth", auth));
        if (null != resultSet) {
            try {
                if (resultSet.next()) {
                    user = resultSet.getString("user");
                    int time = resultSet.getInt("time");
                    resultSet.close();
                    return isValid(time) ? user : null;
                }
                resultSet.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    public boolean isValid(int time) {
        //判断凭证是否过期
        return true;
    }
}
